﻿
@{
    ViewBag.Title = "角色管理";
}


<div>
    <table>
        <tr>
            <td>角色名称:</td>
            <td><input type="text" id="txtRoleName" class="easyui-textbox" /></td>
            <td><a id="btnSearch" href="javascript:onSearch()" class="easyui-linkbutton">查询</a>  </td>
        </tr>
    </table>
</div>
<div id="data-grid"></div>
<div id="dialog"></div>

<script>
    $(function () {
        Init();
        onHide();
    });

    function Init() {
        $("#data-grid").datagrid({
            title: "角色列表",
            singleSelect: true,
            url: "/Base/BaseRole/GetList",
            columns: [[
                { field: 'RoleName', title: '角色名称', width: 100, align: "center" },
                { field: 'Sym', title: '编号', width: 100, align: "center" },
                { field: 'Value', title: '取值', width: 100, align: "center" },
                { field: 'Remark', title: '备注', width: 100, align: "center" },
                {
                    field: 'Enable', title: '是否启用', width: 100, align: "center", formatter: function (v) {
                        return v == 1 ? "启用" : "停用";
                    }
                },
                {
                    field: 'CreateDate', title: '创建时间', width: 100, align: "center", formatter: function (v, r, i) {
                        return ConvertToJsonDateTime(v);
                    }
                }
            ]]
        });
    }

    function onHide() {
        $("#btnImport").hide();
        $("#btnExport").hide();
    }

    function onAdd() {
        var href = "/Base/BaseRole/Add";
        showDialog({ title: "添加角色", href: href });
    }

    function onEdit() {
        if (getSelectRows()) {
            var row = getSelectRows();
            var href = "/Base/BaseRole/Edit?Id=" + row.Id;
            showDialog({ title: '修改角色', href: href });
        }
    }

    function onLook() {
        if (getSelectRows()) {
            var row = getSelectRows();
            var href = "/Base/BaseRole/Edit?Id=" + row.Id;
            showDialog({ title: '查看角色', href: href });
            $("#dialogBtnOK").hide();
        }
    }

    //function onExport() {

    //}

    //function onImport() {

    //}

    function onDelete() {
        if (getSelectRows()) {
            $.messager.confirm("提示信息", "您确定要删除当前数据？", function (d) {
                if (d) {
                    $.post("/Base/BaseRole/Delete", { Id: row.Id }, function (data) {
                        if (data.Success) {
                            $.messager.alert("提示信息", "删除成功!");
                            $("#data-grid").datagrid("reload");
                        }
                    },
                        "json"
                    );
                }
            });
        }
    }


    function onSearch() {
        var text = $("#txtRoleName").textbox("getValue");
        $("#data-grid").datagrid("load", { roleName: $("#txtRoleName").textbox("getValue") });
    }


</script>